<body>
<?php include 'header.phtml';?>
</div>
<div class="AppContent GridView">
	<div id="StickyDetailsAndRelationsBreadCrumbView" class="BreadCrumbView">
		<div class="breadcrumbs">
			<a href="<?php echo $this->basePath();?>/opportunity">Opportunities</a> &#47; 
			<span><?php echo $this->form->get('name')->getValue();?></span>
		</div>
	</div>
	<div id="OpportunityEditAndDetailsView" class="SecuredEditAndDetailsView EditAndDetailsView DetailsView ModelView ConfigurableMetadataView MetadataView">
		<div class="details-table">
			<h1>
				<span class="truncated-title">
					<span class="ellipsis-content">
						<?php echo $this->form->get('name')->getValue();?>
					</span>
				</span>
			</h1>
			<div class="view-toolbar-container toolbar-mbmenu clearfix">
				<div class="view-toolbar">
					<ul class="options-menu nav">
						<li class="parent last"><a href="javascript:void(0);"><span>Options</span></a>
							<ul>
								<li id="EditLinkActionElement">
									<a id="EditLinkActionElement-3-yt2" href="<?php echo $this->url('opportunity', array('action'=>'edit', 'id' => $this->form->get('id')->getValue()));?>">
										<span>Edit</span>
									</a>
								</li>
								<li>
									<a href="<?php echo $this->url('opportunity', array('action'=>'delete', 'id' => $this->form->get('id')->getValue()));?>">Delete</a>

								</li>
									<!--li class="last"><a id="CopyLinkActionElement-3-yt4" href="/zurmo/app/index.php/products/default/copy?id=3"><span>Clone</span></a></li-->
							</ul>
						</li>
					</ul>
				</div>
			</div>
			<div class="left-column full-width">
				<div class="panel">
					<?php
 						$form = $this->form;
 						$form->setAttribute('action', $this->url(
     						'opportunity',
     						array(
         						'action' => 'detail',
         						'id'     => $this->id,
     						)
 						));
 						$form->prepare();
						echo $this->form()->openTag($form);
 						echo $this->formHidden($form->get('id'));?>
					<table class="form-fields">
					<colgroup>
						<col class="col-0" />
						<col class="col-1" />
					</colgroup>
					<tbody>
						<tr>
							<th>Name</th>
								<td colspan="1">
									<?php echo $this->form->get('name')->getValue();?>
								</td>
						</tr>
						<tr>
							<th>Amount</th>
							<td colspan="1">
								<?php echo $this->form->get('amount')->getValue();?>
							</td>
						</tr>
						<tr>
							<th>Close Date</th>
							<td colspan="1">
								<?php echo $this->form->get('closedate')->getValue();?>
								
							</td>
						</tr>
						<tr>
							<th>Stage</th>
							<td colspan="1">
									<?php echo $this->form->get('stage')->getValue();?>
							</td>
						</tr>
						<tr>
							<th>Probability</th>
							<td colspan="1">
									<?php echo $this->form->get('probability')->getValue();?>
							</td>
						</tr>
						<tr>
							<th>Source</th>
							<td colspan="1">
									<?php echo $this->form->get('source')->getValue();?>
							</td>
						</tr>
						<tr>
							<th>Description</th>
							<td colspan="1">
									<?php echo $this->form->get('description')->getValue();?>
							</td>
						</tr>
					</tbody>
					</table>
				</div>
				<p class="after-form-details-content">Last Modified 12/13/13 1:58 PM&#160;by&#160;Super User&#160;|&#160;Created On 12/13/13 1:58 PM&#160;by&#160;Super User&#160;|&#160;Owner <a href="/zurmo/app/index.php/users/default/details?id=4">Jim Smith</a>&#160;|&#160;Who can read and write Owner</p>
			</div>
		</div>
	</div>
</div>
<div id="FlashMessageView">
	<div id = "FlashMessageBar">
	</div>
</div>
</div>
<div id="ModalContainerView">
	<div id="modalContainer"></div>
</div>
<div id="ModalGameNotificationContainerView"></div>
<div id="GameCoinContainerView"></div>
<div id="FooterView">
	<a href="http://www.zurmo.com" id="credit-link" class="clearfix">
		<span>Copyright &#169; Zurmo Inc., 2013. All rights reserved.</span>
	</a>
	<div class="ui-chooser">
		<a class="icon-mobile" href="/zurmo/app/index.php/zurmo/default/userInterface?userInterface=Mobile">
			<span>Show Mobile</span>
		</a>
		<a class="icon-desktop active" href="/zurmo/app/index.php/zurmo/default/userInterface?userInterface=Desktop">
			<span>Show Full</span>
		</a>
	</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
/*<![CDATA[*/
function closeGamificationDashboard(){
                           $('#UserGameDashboardView').remove();
                           $('body').removeClass('gd-dashboard-active');
                           $('#header-game-dashboard-link').html('∂').toggleClass('highlighted');
                       }
                       
            jQuery.datepicker._gotoToday = function (id) {            
                var inst = this._getInst($(id)[0]);
                dp = inst.dpDiv;                                
                var now = new Date();
                jQuery.datepicker._base_gotoToday(id);
                now.setMinutes(now.getMinutes()+(420)+now.getTimezoneOffset());
                this._setTime(inst, now);     
                $('.ui-datepicker-today', dp).click();
            };            
        

                function clearIdFromAutoCompleteField(value, id)
                {
                    if (value == '')
                    {
                        $('#' + id).val('');
                    }
                }
            

                function closeOpenTaskByCheckBoxClick(checkboxId, modelId)
                {
                    if ($('#' + checkboxId).attr('checked') == 'checked')
                    {
                        $('#' + checkboxId).attr('disabled', true);
                        $('#' + checkboxId).parent().addClass('c_on');
                        $('#' + checkboxId).parent().addClass('disabled');
                        $('#' + checkboxId).parentsUntil('tr').parent().children().css('text-decoration', 'line-through');
                        $.ajax({
                            url : '/zurmo/app/index.php/tasks/default/closeTask?id=' + modelId,
                            type : 'GET',
                            dataType : 'json',
                            success : function(data)
                            {
                                //find if there is a latest activities portlet
                                $('.LatestActivitiesForPortletView').each(function(){
                                    $(this).find('.pager').find('.refresh').find('a').click();
                                });
                            },
                            error : function()
                            {
                                //todo: error call
                            }
                        });
                    }
                }
            
jQuery(function($) {

                    jQuery("body").ajaxComplete(
                        function(event, request, options)
                        {
                            if (request.responseText == "sessionTimeout")
                            {
                                $.cookie("sessionTimeoutCookie", 1,
                                        {
                                            expires : 1,
                                            path:  "/"
                                        });
                                window.location.reload(true);
                            }
                        }
                    );
                
$('#go-to-dashboard-link, #close-game-notification-link').click(function(event){
                           event.preventDefault();
                           $('#game-notification').fadeOut(300, function(){
                               $('#game-notification').remove();
                           });
                       });
                       $('.gd-dashboard-active').on('click', function(){
                           if($('#UserGameDashboardView').length){
                               closeGamificationDashboard();
                           }
                           return false;
                       });
$('body').on('click', '#header-game-dashboard-link', function(){jQuery.ajax({'beforeSend':function(){
                    if($("#UserGameDashboardView").length){
                        closeGamificationDashboard();
                        return false;
                    }
                    $("body").addClass("gd-dashboard-active");
                    $("#header-game-dashboard-link").html("‰").toggleClass("highlighted");
                },'success':function(data){$("#FooterView").after(data);},'url':'/zurmo/app/index.php/users/default/gameDashboard?id=1','cache':false});return false;});
  $(".nav li").hover(
    function () {
      if ($(this).hasClass("parent")) {
        $(this).addClass("over");
      }
    },
    function () {
      $(this).removeClass("over");
    }
  );

$("#globalSearchScope").bind("multiselectclick", function(event, ui){
                            if ($("#globalSearchScope").multiselect("widget").find(":checkbox:checked").length == 0)
                            {
                                $("#globalSearchScope").multiselect("widget").find(":checkbox").each(function(){
                                    if (this.value == "All" && !this.checked)
                                    {
                                        this.click();
                                    }
                                });
                            }
                            if (ui.value == "All" && ui.checked)
                            {
                                $("#globalSearchScope").multiselect("widget").find(":checkbox").each(function(){
                                    if (this.value != "All" && this.checked)
                                    {
                                        this.click();
                                    }
                                });
                            }
                            else if (ui.value != "All" && ui.checked)
                            {
                                $("#globalSearchScope").multiselect("widget").find(":checkbox").each(function(){
                                    if (this.value == "All" && this.checked)
                                    {
                                        this.click();
                                    }
                                });
                            }
                        });
                       
$('#globalSearchScope').multiselect({'selectedText':'','noneSelectedText':'','header':false,'position':{'my':'right top','at':'right bottom'}}); $(this).setupCheckboxStyling($('#globalSearchScope').parent())
$("#globalSearchInput").bind("focus", function(event, ui){
                            $("#globalSearchInput").autocomplete("option", "source", "/zurmo/app/index.php/zurmo/default/globalSearchAutoComplete?" + $.param($("#globalSearchScope").serializeArray()));
                        });
                       
jQuery('#globalSearchInput').autocomplete({'select': function(event, ui) {if (ui.item.href.length > 0){window.location = ui.item.href;} return false;},'search': function(event, ui) { $(this).makeOrRemoveTogglableSpinner(true, "#app-search") },'open': function(event, ui) { $(this).makeOrRemoveTogglableSpinner(false, "#app-search") },'position':{'my':'right top','at':'right bottom'},'source':'/zurmo/app/index.php/zurmo/default/globalSearchAutoComplete'});
 $("#globalSearchInput").data( "autocomplete" )._renderItem = function( ul, item ) {
                            return $( "<li></li>" ).data( "item.autocomplete", item )
                                    .append( "<a><span class=" + item.iconClass + "></span><span>" + item.label + "</span></a>" )
                                    .appendTo( ul );
                        };
$('body').on('click', '#yt0', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                window.scrollTo(0, 0);
                jQuery('#modalContainer').dialog({
                    'title' : 'Create Task',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : 'task-dialog',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer').parent().removeClass('openingModal');
                                                     $('#modalContainer').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/tasks/default/modalCreate?modalId=modalContainer','cache':false,'success':function(html){jQuery("#modalContainer").html(html)}});return false;});
$(document).ready(function () { jQuery.ajax({'type':'GET','url':'/zurmo/app/index.php/opportunities/default/renderStickyListBreadCrumbContent?stickyKey=OpportunitiesSearchView&stickyOffset=0&stickyModelId=11','cache':false,'data':jQuery(this).parents("form").serialize(),'success':function(html){jQuery("#stickyListLoadingArea").html(html)}});});
$('body').off('click.update', '#star-Opportunity-11'); $('body').on('click.update', '#star-Opportunity-11', function(){jQuery.ajax({'success':function(data){$('#star-Opportunity-11').removeClass().addClass(data)},'url':'/zurmo/app/index.php/zurmo/default/toggleStar?modelClassName=Opportunity&modelId=11','cache':false});return false;});
$('body').on('click', '#AuditEventsModalListLinkActionElement-11-yt4', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#AuditEventsModalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#AuditEventsModalContainer');
                window.scrollTo(0, 0);
                jQuery('#AuditEventsModalContainer').dialog({
                    'title' : 'Audit Trail',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : '',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#AuditEventsModalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#AuditEventsModalContainer').parent().removeClass('openingModal');
                                                     $('#AuditEventsModalContainer').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/opportunities/default/auditEventsModalList?id=11','cache':false,'success':function(html){jQuery("#AuditEventsModalContainer").html(html)}});return false;});
jQuery('body').on('click','#OpportunityDeleteLinkActionElement-11-yt6',function(){return confirm('Are you sure you want to delete this opportunity?');});
$(function () {
    'use strict';

    // Initialize the jQuery File Upload widget:
    $('#fileUploadNote').fileupload({
        dataType: 'json',
        url: '/zurmo/app/index.php/zurmo/fileModel/upload?filesVariableName=Note_files',
        autoUpload: true,
        sequentialUploads: true,
        maxFileSize: 1048576,
        add: function (e, data) {
            
            
            var that = $(this).data('fileupload');
            that._adjustMaxNumberOfFiles(-data.files.length);
            data.isAdjusted = true;
            data.isValidated = that._validate(data.files);
            data.context = that._renderUpload(data.files)
                .appendTo($(this).find('.files')).fadeIn(function () {
                    // Fix for IE7 and lower:
                    $(this).show();
                    $(this).makeOrRemoveTogglableSpinner(true, '#'+'fileUploadNote');
                }).data('data', data);
            if ((that.options.autoUpload || data.autoUpload) &&
                    data.isValidated) {
                data.jqXHR = data.submit();
            }
        }
    });
    // Open download dialogs via iframes,
    // to prevent aborting current uploads:
    $('#fileUploadNote .files a:not([target^=_blank])').live('click', function (e) {
        e.preventDefault();
        $('<iframe style="display:none;"></iframe>')
            .prop('src', this.href)
            .appendTo('body');
    });
    $('.fileupload-buttonbar').removeClass('ui-widget-header ui-corner-top');
    $('.fileupload-content').removeClass('ui-widget-content ui-corner-bottom');
    $('#fileUploadNote').bind('fileuploaddestroy', function (e, data) {
            

    });
    $('#fileUploadNote').bind('fileuploadalways', function (e, data) {
        if (data == undefined || data.result == undefined ||
          ((data.result[0] != undefined && data.result[0].error != undefined) || data.result.error != undefined))
        {
            setTimeout(function () {
               $('#inline-edit-form').find('.files > tbody').children(':last').fadeOut('slow', function() { $(this).remove();});
               
            }, 1000);
        }
    });
    //load existing files
    var existingFiles = [];
    var fu = $('#fileUploadNote').data('fileupload');
    fu._adjustMaxNumberOfFiles(-existingFiles.length);
    fu._renderDownload(existingFiles)
        .appendTo($('#fileUploadNote .files'))
        .fadeIn(function () {
            // Fix for IE7 and lower:
            $(this).show();
    });
});

jQuery('#Note_occurredOnDateTime').datetimepicker({'stepMinute':5,'timeText':'Time','hourText':'Hour','minuteText':'Minute','secondText':'Second','showOn':'both','buttonText':'<span><!--Date--><\/span>','buttonImageOnly':false,'timeFormat':'h:mm tt','dateFormat':'m/d/yy','currentText':'<span class=\"z-label\">Now<\/span>','closeText':'<span class=\"z-label\">Done<\/span>'});
jQuery('#ActivityItemForm_Account_name').autocomplete({'select':function(event, ui){ jQuery("#ActivityItemForm_Account_id").val(ui.item["id"]).trigger("change");},'appendTo':$("#ActivityItemForm_Account_name").parent().parent(),'search': function(event, ui)
                                  {
                                       var context = $("#ActivityItemForm_Account_name").parent();
                                       $(".model-select-icon", context).fadeOut(100);
                                       $(this).makeOrRemoveTogglableSpinner(true, context);
                                  },'open': function(event, ui)
                                  {
                                       var context = $("#ActivityItemForm_Account_name").parent();
                                       $(".model-select-icon", context).fadeIn(250);
                                       $(this).makeOrRemoveTogglableSpinner(false, context);
                                  },'close': function(event, ui)
                                  {
                                       var context = $("#ActivityItemForm_Account_name").parent();
                                       $(".model-select-icon", context).fadeIn(250);
                                       $(this).makeOrRemoveTogglableSpinner(false, context);
                                  },'response': function(event, ui)
                                  {
                                       if (ui.content.length < 1)
                                       {
                                           var context = $("#ActivityItemForm_Account_name").parent();
                                           $(".model-select-icon", context).fadeIn(250);
                                           $(this).makeOrRemoveTogglableSpinner(false, context);
                                       }
                                  },'source':'/zurmo/app/index.php/accounts/default/autoComplete'});
$('body').off('click.selectLink', '#ActivityItemForm_Account_SelectLink'); $('body').on('click.selectLink', '#ActivityItemForm_Account_SelectLink', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer-inline-edit-form').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer-inline-edit-form');
                window.scrollTo(0, 0);
                jQuery('#modalContainer-inline-edit-form').dialog({
                    'title' : 'Account Search',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : '',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer-inline-edit-form').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer-inline-edit-form').parent().removeClass('openingModal');
                                                     $('#modalContainer-inline-edit-form').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/accounts/default/modalList?modalTransferInformation%5BsourceIdFieldId%5D=ActivityItemForm_Account_id&modalTransferInformation%5BsourceNameFieldId%5D=ActivityItemForm_Account_name&modalTransferInformation%5BmodalId%5D=modalContainer-inline-edit-form&modalTransferInformation%5BsourceModelId%5D=','cache':false,'success':function(html){jQuery("#modalContainer-inline-edit-form").html(html)}});return false;});
jQuery('#ActivityItemForm_Contact_name').autocomplete({'select':function(event, ui){ jQuery("#ActivityItemForm_Contact_id").val(ui.item["id"]).trigger("change");},'appendTo':$("#ActivityItemForm_Contact_name").parent().parent(),'search': function(event, ui)
                                  {
                                       var context = $("#ActivityItemForm_Contact_name").parent();
                                       $(".model-select-icon", context).fadeOut(100);
                                       $(this).makeOrRemoveTogglableSpinner(true, context);
                                  },'open': function(event, ui)
                                  {
                                       var context = $("#ActivityItemForm_Contact_name").parent();
                                       $(".model-select-icon", context).fadeIn(250);
                                       $(this).makeOrRemoveTogglableSpinner(false, context);
                                  },'close': function(event, ui)
                                  {
                                       var context = $("#ActivityItemForm_Contact_name").parent();
                                       $(".model-select-icon", context).fadeIn(250);
                                       $(this).makeOrRemoveTogglableSpinner(false, context);
                                  },'response': function(event, ui)
                                  {
                                       if (ui.content.length < 1)
                                       {
                                           var context = $("#ActivityItemForm_Contact_name").parent();
                                           $(".model-select-icon", context).fadeIn(250);
                                           $(this).makeOrRemoveTogglableSpinner(false, context);
                                       }
                                  },'source':'/zurmo/app/index.php/contacts/variableContactState/autoCompleteAllContacts'});
$('body').off('click.selectLink', '#ActivityItemForm_Contact_SelectLink'); $('body').on('click.selectLink', '#ActivityItemForm_Contact_SelectLink', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer-inline-edit-form').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer-inline-edit-form');
                window.scrollTo(0, 0);
                jQuery('#modalContainer-inline-edit-form').dialog({
                    'title' : 'Contact Search',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : '',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer-inline-edit-form').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer-inline-edit-form').parent().removeClass('openingModal');
                                                     $('#modalContainer-inline-edit-form').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/contacts/variableContactState/modalListAllContacts?modalTransferInformation%5BsourceIdFieldId%5D=ActivityItemForm_Contact_id&modalTransferInformation%5BsourceNameFieldId%5D=ActivityItemForm_Contact_name&modalTransferInformation%5BmodalId%5D=modalContainer-inline-edit-form&modalTransferInformation%5BsourceModelId%5D=','cache':false,'success':function(html){jQuery("#modalContainer-inline-edit-form").html(html)}});return false;});
jQuery('#ActivityItemForm_Opportunity_name').autocomplete({'select':function(event, ui){ jQuery("#ActivityItemForm_Opportunity_id").val(ui.item["id"]).trigger("change");},'appendTo':$("#ActivityItemForm_Opportunity_name").parent().parent(),'search': function(event, ui)
                                  {
                                       var context = $("#ActivityItemForm_Opportunity_name").parent();
                                       $(".model-select-icon", context).fadeOut(100);
                                       $(this).makeOrRemoveTogglableSpinner(true, context);
                                  },'open': function(event, ui)
                                  {
                                       var context = $("#ActivityItemForm_Opportunity_name").parent();
                                       $(".model-select-icon", context).fadeIn(250);
                                       $(this).makeOrRemoveTogglableSpinner(false, context);
                                  },'close': function(event, ui)
                                  {
                                       var context = $("#ActivityItemForm_Opportunity_name").parent();
                                       $(".model-select-icon", context).fadeIn(250);
                                       $(this).makeOrRemoveTogglableSpinner(false, context);
                                  },'response': function(event, ui)
                                  {
                                       if (ui.content.length < 1)
                                       {
                                           var context = $("#ActivityItemForm_Opportunity_name").parent();
                                           $(".model-select-icon", context).fadeIn(250);
                                           $(this).makeOrRemoveTogglableSpinner(false, context);
                                       }
                                  },'source':'/zurmo/app/index.php/opportunities/default/autoComplete'});
$('body').off('click.selectLink', '#ActivityItemForm_Opportunity_SelectLink'); $('body').on('click.selectLink', '#ActivityItemForm_Opportunity_SelectLink', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer-inline-edit-form').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer-inline-edit-form');
                window.scrollTo(0, 0);
                jQuery('#modalContainer-inline-edit-form').dialog({
                    'title' : 'Opportunity Search',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : '',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer-inline-edit-form').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer-inline-edit-form').parent().removeClass('openingModal');
                                                     $('#modalContainer-inline-edit-form').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/opportunities/default/modalList?modalTransferInformation%5BsourceIdFieldId%5D=ActivityItemForm_Opportunity_id&modalTransferInformation%5BsourceNameFieldId%5D=ActivityItemForm_Opportunity_name&modalTransferInformation%5BmodalId%5D=modalContainer-inline-edit-form&modalTransferInformation%5BsourceModelId%5D=','cache':false,'success':function(html){jQuery("#modalContainer-inline-edit-form").html(html)}});return false;});

                    $('#show-more-panels-link-yt7').click( function()
                        {
                            $('.more-view-panel-' + $(this).attr('href')).show();
                            $('#show-more-panels-link-yt7').hide();
                            $('#show-less-panels-link-yt7').show();
                            return false;
                        }
                    );
                    $('#show-less-panels-link-yt7').click( function()
                        {
                            $('.more-view-panel-' + $(this).attr('href')).hide();
                            $('#show-more-panels-link-yt7').show();
                            $('#show-less-panels-link-yt7').hide();
                            return false;
                        }
                    );
$("#post-to-profile-note-tooltip").qtip([]);
$('#inline-edit-form').yiiactiveform({'validateOnSubmit':true,'validateOnChange':false,'beforeValidate':$(this).beforeValidateAction,'afterValidate':$(this).afterValidateAjaxAction,'afterValidateAjax':'jQuery.ajax({\'type\':\'POST\',\'data\':$(\"#inline-edit-form\").serialize(),\'url\':\'/zurmo/app/index.php/notes/default/inlineCreateSave?redirectUrl=%2Fzurmo%2Fapp%2Findex.php%2Fopportunities%2FdefaultPortlet%2Fdetails%3Fid%3D11%26stickyOffset%3D0%26portletId%3D2%26uniqueLayoutId%3DOpportunityDetailsAndRelationsView_2\',\'complete\':function(XMLHttpRequest, textStatus){\n                        //find if there is a latest activities portlet\n                        $(\'.LatestActivitiesForPortletView\').each(function(){\n                            $(this).find(\'.pager\').find(\'.refresh\').find(\'a\').click();\n                        });},\'cache\':false,\'success\':function(html){jQuery(\"#NoteInlineEditForPortletView\").html(html)}});','attributes':[{'id':'Note_description','inputID':'Note_description','errorID':'Note_description_em_','model':'Note','name':'description','enableAjaxValidation':true},{'id':'Note_occurredOnDateTime','inputID':'Note_occurredOnDateTime','errorID':'Note_occurredOnDateTime_em_','model':'Note','name':'occurredOnDateTime','enableAjaxValidation':true},{'id':'ActivityItemForm_Account','inputID':'ActivityItemForm_Account','errorID':'ActivityItemForm_Account_em_','model':'ActivityItemForm','name':'Account','enableAjaxValidation':true},{'id':'ActivityItemForm_Contact','inputID':'ActivityItemForm_Contact','errorID':'ActivityItemForm_Contact_em_','model':'ActivityItemForm','name':'Contact','enableAjaxValidation':true},{'id':'ActivityItemForm_Opportunity','inputID':'ActivityItemForm_Opportunity','errorID':'ActivityItemForm_Opportunity_em_','model':'ActivityItemForm','name':'Opportunity','enableAjaxValidation':true}],'summaryID':'inline-edit-form_es_'});
$("#activities-rollup-tooltip").qtip([]);

            $('#LatestActivitiesConfigurationForm_rollup_area').buttonset();
            $('#LatestActivitiesConfigurationForm_ownedByFilter_area').buttonset();
            $('#LatestActivitiesConfigurationForm_filteredByModelName_area').buttonset();
            $('#LatestActivitiesConfigurationForm_rollup_area').change(function()
                {
                    jQuery.ajax({'type':'GET','data':$("#latest-activity-configuration-form").serialize(),'url':$.param.querystring("/zurmo/app/index.php/opportunities/defaultPortlet/details?id=11&stickyOffset=0&portletId=3&uniqueLayoutId=OpportunityDetailsAndRelationsView_3", "OpportunityLatestActivitiesForPortletView_page=1"),'beforeSend':function(){$(this).makeSmallLoadingSpinner(true, "#list-viewOpportunityLatestActivitiesForPortletView"); $("#latest-activity-configuration-form").parent().children(".cgrid-view").addClass("loading");},'complete':function()
                    {
                                        $("#latest-activity-configuration-form").parent().children(".cgrid-view").removeClass("loading");
                                        $("#filter-portlet-model-bar-OpportunityLatestActivitiesForPortletView").show();
                    },'cache':false,'success':function(html){jQuery("#OpportunityLatestActivitiesForPortletView").html(html)}});
                }
            );
            $('#LatestActivitiesConfigurationForm_ownedByFilter_area').change(function()
                {
                    jQuery.ajax({'type':'GET','data':$("#latest-activity-configuration-form").serialize(),'url':$.param.querystring("/zurmo/app/index.php/opportunities/defaultPortlet/details?id=11&stickyOffset=0&portletId=3&uniqueLayoutId=OpportunityDetailsAndRelationsView_3", "OpportunityLatestActivitiesForPortletView_page=1"),'beforeSend':function(){$(this).makeSmallLoadingSpinner(true, "#list-viewOpportunityLatestActivitiesForPortletView"); $("#latest-activity-configuration-form").parent().children(".cgrid-view").addClass("loading");},'complete':function()
                    {
                                        $("#latest-activity-configuration-form").parent().children(".cgrid-view").removeClass("loading");
                                        $("#filter-portlet-model-bar-OpportunityLatestActivitiesForPortletView").show();
                    },'cache':false,'success':function(html){jQuery("#OpportunityLatestActivitiesForPortletView").html(html)}});
                }
            );
            $('#LatestActivitiesConfigurationForm_filteredByModelName_area').change(function()
                {
                    jQuery.ajax({'type':'GET','data':$("#latest-activity-configuration-form").serialize(),'url':$.param.querystring("/zurmo/app/index.php/opportunities/defaultPortlet/details?id=11&stickyOffset=0&portletId=3&uniqueLayoutId=OpportunityDetailsAndRelationsView_3", "OpportunityLatestActivitiesForPortletView_page=1"),'beforeSend':function(){$(this).makeSmallLoadingSpinner(true, "#list-viewOpportunityLatestActivitiesForPortletView"); $("#latest-activity-configuration-form").parent().children(".cgrid-view").addClass("loading");},'complete':function()
                    {
                                        $("#latest-activity-configuration-form").parent().children(".cgrid-view").removeClass("loading");
                                        $("#filter-portlet-model-bar-OpportunityLatestActivitiesForPortletView").show();
                    },'cache':false,'success':function(html){jQuery("#OpportunityLatestActivitiesForPortletView").html(html)}});
                }
            );
            $('#filter-latest-activities-link').click( function()
                {
                    $('#filter-portlet-model-bar-OpportunityLatestActivitiesForPortletView').toggle();
                    return false;
                }
            );
            
$(document).on('click', '#list-viewOpportunityLatestActivitiesForPortletView .task-kanban-detail-link', function()
                          {
                            var id = $(this).attr('id');
                            var idParts = id.split('-');
                            var taskId = parseInt(idParts[1]);
                            $.ajax(
                            {
                                'type' : 'GET',
                                'url'  : '/zurmo/app/index.php/tasks/default/modalDetails' + '?id=' + taskId,
                                'beforeSend' : function(){
                jQuery('#modalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                window.scrollTo(0, 0);
                jQuery('#modalContainer').dialog({
                    'title' : 'Collaborate On This Task',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : 'task-dialog',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer').parent().removeClass('openingModal');
                                                     $('#modalContainer').dialog('destroy');
                                                     $.fn.yiiGridView.update('list-viewOpportunityLatestActivitiesForPortletView');
                                                     }
                });
                return true;
            },
                                'update'     : '#modalContainer',
                                'success': function(html){jQuery('#modalContainer').html(html)}
                            });
                          }
                        );
jQuery('#list-viewOpportunityLatestActivitiesForPortletView').yiiGridView({'ajaxUpdate':['list-viewOpportunityLatestActivitiesForPortletView'],'ajaxVar':'ajax','pagerClass':'pager horizontal','loadingClass':'loading','filterClass':'filters','tableClass':'items','selectableRows':0,'enableHistory':false,'updateSelector':'{page}, {sort}','filterSelector':'{filter}','pageVar':'OpportunityLatestActivitiesForPortletView_page','beforeAjaxUpdate':function(id, options) { $(this).makeSmallLoadingSpinner(true, "#" + id); },'afterAjaxUpdate':function(id, data) {
                        processAjaxSuccessError(id, data);
                    }});
var calendarEvents = {}; 
calendarEvents[new Date('Nov 24, 2013')] = new CalendarEvent('1 Meeting', 'calendar-events-1'); 
calendarEvents[new Date('Nov 19, 2013')] = new CalendarEvent('1 Meeting', 'calendar-events-1'); 

jQuery('#calendarOpportunityDetailsAndRelationsView_4_container').datepicker({'dateFormat':'m/d/y','onChangeMonthYear':function(year, month, inst) {
                //Call to render new events
                $.ajax({
                    url      : $.param.querystring('/zurmo/app/index.php/opportunities/defaultPortlet/viewAction?id=11&stickyOffset=0&action=renderMonthEvents&portletId=4&uniqueLayoutId=OpportunityDetailsAndRelationsView_4', '&month=' + month + '&year=' + year),
                    async    : false,
                    type     : 'GET',
                    dataType : 'html',
                    success  : function(data)
                    {
                        eval(data);
                        //Since the home page for some reason cannot render this properly in beforeShow, we are using a trick.
                        setTimeout('addSpansToDatesOnCalendar("' + inst.id + '")', 100);
                    },
                    error : function()
                    {
                        //todo: error call
                    }
                });
            },'onSelect':function(dateText, inst) {
                $.ajax({
                    url      : $.param.querystring('/zurmo/app/index.php/meetings/default/daysMeetingsFromCalendarModalList?id=11&stickyOffset=0&redirectUrl=%2Fzurmo%2Fapp%2Findex.php%2Fopportunities%2Fdefault%2Fdetails%3Fid%3D11%26stickyOffset%3D0&relationModelId=11&relationModelClassName=Opportunity', '&stringTime=' + $('#calendarSelectedDateOpportunityDetailsAndRelationsView_4').val()),
                    async    : false,
                    type     : 'GET',
                    'beforeSend' : function(){
                                        jQuery('#modalContainer').html('');
                                        $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                                        jQuery('#modalContainer').dialog({'title': dateText,
                                                                          'autoOpen':true,
                                                                          'modal': true,
                                                                          'height': 'auto',
                                                                          'position': 'center',
                                                                          'width':600}); return true;},
                    success  : function(data)
                    {
                        jQuery('#modalContainer').html(data)
                        //Since the home page for some reason cannot render this properly in beforeShow, we are using a trick.
                        setTimeout('addSpansToDatesOnCalendar("' + inst.id + '")', 100);
                    },
                    error : function()
                    {
                        //todo: error call
                    }
                });
            },'altFormat':'yy-mm-dd','altField':'#calendarSelectedDateOpportunityDetailsAndRelationsView_4','beforeShowDay':function(date) {
                var event = calendarEvents[date];
                if (event) {
                    return [true, event.className, event.text];
                }
                else {
                    return [true, '', ''];
                }
            }});addSpansToDatesOnCalendar("calendarOpportunityDetailsAndRelationsView_4_container");
jQuery('#list-viewOpportunityDetailsAndRelationsView_5').yiiGridView({'ajaxUpdate':['list-viewOpportunityDetailsAndRelationsView_5'],'ajaxVar':'ajax','pagerClass':'pager horizontal','loadingClass':'loading','filterClass':'filters','tableClass':'items','selectableRows':0,'enableHistory':false,'updateSelector':'{page}, {sort}','filterSelector':'{filter}','pageVar':'Task_page','beforeAjaxUpdate':function(id, options) { $(this).makeSmallLoadingSpinner(true, "#" + id); },'afterAjaxUpdate':function(id, data) {
                        processAjaxSuccessError(id, data);
                    }});
$('body').on('click', '#EditModalLinkActionElement-10-yt16', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                window.scrollTo(0, 0);
                jQuery('#modalContainer').dialog({
                    'title' : 'Edit Task',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : 'task-dialog',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer').parent().removeClass('openingModal');
                                                     $('#modalContainer').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/tasks/default/modalEdit?id=10&modalId=modalContainer&portletId=5&uniqueLayoutId=OpportunityDetailsAndRelationsView_5&sourceId=list-viewOpportunityDetailsAndRelationsView_5&relationAttributeName=Opportunity&relationModelId=11&relationModuleId=opportunities&redirectUrl=%2Fzurmo%2Fapp%2Findex.php%2Fopportunities%2Fdefault%2Fdetails%3Fid%3D11%26stickyOffset%3D0','cache':false,'success':function(html){jQuery("#modalContainer").html(html)}});return false;});
$('body').on('click', '#CopyModalLinkActionElement-10-yt17', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                window.scrollTo(0, 0);
                jQuery('#modalContainer').dialog({
                    'title' : 'Copy Task',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : 'task-dialog',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer').parent().removeClass('openingModal');
                                                     $('#modalContainer').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/tasks/default/modalCopy?id=10&action=copy&modalId=modalContainer&portletId=5&uniqueLayoutId=OpportunityDetailsAndRelationsView_5&sourceId=list-viewOpportunityDetailsAndRelationsView_5&relationAttributeName=Opportunity&relationModelId=11&relationModuleId=opportunities&redirectUrl=%2Fzurmo%2Fapp%2Findex.php%2Fopportunities%2Fdefault%2Fdetails%3Fid%3D11%26stickyOffset%3D0','cache':false,'success':function(html){jQuery("#modalContainer").html(html)}});return false;});
$('body').on('click', '#list-viewOpportunityDetailsAndRelationsView_5-delete-10', function(){if (!$(this).onAjaxSubmitRelatedListAction("Are you sure you want to delete this task?", "list-viewOpportunityDetailsAndRelationsView_5")){return;};jQuery.ajax({'error':function(xhr, textStatus, errorThrown) {alert("There was an error processing your request");},'success':function(){$('#list-viewOpportunityDetailsAndRelationsView_5-delete-10').closest('.items').parent()
                                                        .find('.pager').find('.refresh').find('a').click();},'url':'/zurmo/app/index.php/tasks/default/delete?id=10&redirectUrl=%2Fzurmo%2Fapp%2Findex.php%2Fopportunities%2Fdefault%2Fdetails%3Fid%3D11%26stickyOffset%3D0','cache':false});return false;});
$(document).on('click', '#list-viewOpportunityDetailsAndRelationsView_5 .task-kanban-detail-link', function()
                          {
                            var id = $(this).attr('id');
                            var idParts = id.split('-');
                            var taskId = parseInt(idParts[1]);
                            $.ajax(
                            {
                                'type' : 'GET',
                                'url'  : '/zurmo/app/index.php/tasks/default/modalDetails' + '?id=' + taskId,
                                'beforeSend' : function(){
                jQuery('#modalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                window.scrollTo(0, 0);
                jQuery('#modalContainer').dialog({
                    'title' : 'Collaborate On This Task',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : 'task-dialog',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer').parent().removeClass('openingModal');
                                                     $('#modalContainer').dialog('destroy');
                                                     $.fn.yiiGridView.update('list-viewOpportunityDetailsAndRelationsView_5');
                                                     }
                });
                return true;
            },
                                'update'     : '#modalContainer',
                                'success': function(html){jQuery('#modalContainer').html(html)}
                            });
                          }
                        );
$('body').on('click', '#CreateFromRelatedModalLinkActionElement--yt19', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                window.scrollTo(0, 0);
                jQuery('#modalContainer').dialog({
                    'title' : 'Create Task',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : 'task-dialog',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer').parent().removeClass('openingModal');
                                                     $('#modalContainer').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/tasks/default/modalCreateFromRelation?modalId=modalContainer&portletId=5&uniqueLayoutId=OpportunityDetailsAndRelationsView_5&sourceId=list-viewOpportunityDetailsAndRelationsView_5&relationAttributeName=Opportunity&relationModelId=11&relationModuleId=opportunities&redirectUrl=%2Fzurmo%2Fapp%2Findex.php%2Fopportunities%2Fdefault%2Fdetails%3Fid%3D11%26stickyOffset%3D0','cache':false,'success':function(html){jQuery("#modalContainer").html(html)}});return false;});
jQuery('#list-viewOpportunityDetailsAndRelationsView_6').yiiGridView({'ajaxUpdate':['list-viewOpportunityDetailsAndRelationsView_6'],'ajaxVar':'ajax','pagerClass':'pager horizontal','loadingClass':'loading','filterClass':'filters','tableClass':'items','selectableRows':0,'enableHistory':false,'updateSelector':'{page}, {sort}','filterSelector':'{filter}','pageVar':'Contact_page','beforeAjaxUpdate':function(id, options) { $(this).makeSmallLoadingSpinner(true, "#" + id); },'afterAjaxUpdate':function(id, data) {
                        processAjaxSuccessError(id, data);
                    }});
$('body').on('click', '.composeEmailLink', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                window.scrollTo(0, 0);
                jQuery('#modalContainer').dialog({
                    'title' : 'Compose Email',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : {"my":"top","at":"bottom","of":"#HeaderView"},
                    'dialogClass' : '',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer').parent().removeClass('openingModal');
                                                     $('#modalContainer').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':$(this).attr("href"),'cache':false,'success':function(html){jQuery("#modalContainer").html(html)}});return false;});
$('body').on('click', '#list-viewOpportunityDetailsAndRelationsView_6-createEmail-12', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                window.scrollTo(0, 0);
                jQuery('#modalContainer').dialog({
                    'title' : 'Compose Email',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : {"my":"top","at":"bottom","of":"#HeaderView"},
                    'dialogClass' : '',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer').parent().removeClass('openingModal');
                                                     $('#modalContainer').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/emailMessages/default/createEmailMessage?relatedModelClassName=Contact&relatedId=12','cache':false,'success':function(html){jQuery("#modalContainer").html(html)}});return false;});
$('body').on('click', '#list-viewOpportunityDetailsAndRelationsView_6-delete-12', function(){if (!$(this).onAjaxSubmitRelatedListAction("Are you sure you want to delete this contact?", "list-viewOpportunityDetailsAndRelationsView_6")){return;};jQuery.ajax({'error':function(xhr, textStatus, errorThrown) {alert("There was an error processing your request");},'success':function(){$('#list-viewOpportunityDetailsAndRelationsView_6-delete-12').closest('.items').parent()
                                                        .find('.pager').find('.refresh').find('a').click();},'url':'/zurmo/app/index.php/contacts/default/delete?id=12&redirectUrl=%2Fzurmo%2Fapp%2Findex.php%2Fopportunities%2Fdefault%2Fdetails%3Fid%3D11%26stickyOffset%3D0','cache':false});return false;});
$('body').on('click', '#list-viewOpportunityDetailsAndRelationsView_6-unlink-12', function(){if (!$(this).onAjaxSubmitRelatedListAction("Are you sure you want to unlink this contact?", "list-viewOpportunityDetailsAndRelationsView_6")){return;};jQuery.ajax({'error':function(xhr, textStatus, errorThrown) {alert("There was an error processing your request");},'success':function(){$('#list-viewOpportunityDetailsAndRelationsView_6-unlink-12').closest('.items').parent()
                                                        .find('.pager').find('.refresh').find('a').click();},'url':'/zurmo/app/index.php/contacts/default/unlink?id=12&relationModelClassName=Opportunity&relationModelId=11&relationModelRelationName=contacts&redirectUrl=%2Fzurmo%2Fapp%2Findex.php%2Fopportunities%2Fdefault%2Fdetails%3Fid%3D11%26stickyOffset%3D0','cache':false});return false;});
$('#SelectContactsForOpportunityFromRelatedListLink').on('click', function(){jQuery.ajax({'beforeSend':function(){
                jQuery('#modalContainer').html('');
                $(this).makeLargeLoadingSpinner(true, '#modalContainer');
                window.scrollTo(0, 0);
                jQuery('#modalContainer').dialog({
                    'title' : 'Contact Search',
                    'autoOpen' : true,
                    'modal' : true,
                    'position' : 'center top+25',
                    'dialogClass' : '',
                    'height' : 'auto',
                    'open': function( event, ui )  { jQuery('#modalContainer').parent().addClass('openingModal'); },
                    'close': function( event, ui ) { jQuery('#modalContainer').parent().removeClass('openingModal');
                                                     $('#modalContainer').dialog('destroy');
                                                     
                                                     }
                });
                return true;
            },'url':'/zurmo/app/index.php/contacts/default/selectFromRelatedList?uniqueLayoutId=OpportunityDetailsAndRelationsView_6&portletId=6&relationAttributeName=opportunities&relationModelId=11&relationModuleId=opportunities&relationModelClassName=','cache':false,'success':function(html){jQuery("#modalContainer").html(html)}});return false;});
juiPortlets.init('OpportunityDetailsAndRelationsView','opportunities', '/zurmo/app/index.php/opportunities/defaultPortlet/SaveLayout', 'YII_CSRF_TOKEN', '3a494af6956666c752fc7c885c945f0c519c2c52', '.juiportlet-columns-OpportunityDetailsAndRelationsView', '', '', 'This portlet will be removed, ok?');
});
/*]]>*/
</script>
</body></html>